﻿using System;
using System.Data.SqlClient;
using System.Web.UI;

namespace 上课演示
{
    public partial class CommandDemo : Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            string connectionString = "server=.;database=schooldb;Trusted_Connection=SSPI";
            var connection = new SqlConnection(connectionString);
            var command = new SqlCommand("SELECT * FROM STUDENT", connection);

            //command.CommandText = "DELETE FROM STUDENT WHERE SNO='95006'";
            //command.CommandText = "UPDATE STUDENT SET SNAME='JANE' WHERE SNO='95005'";


            connection.Open();
            SqlDataReader reader = command.ExecuteReader();

            while (reader.Read())
            {
                String s = "";
                s += reader["SNO"];
                s += reader["SNAME"];
                s += reader["SSEX"];
                s += reader["SAGE"];

                Response.Write(s);
            }

            connection.Close();
        }
    }
}